import os

def splitFileName(fname):
    """resolves problems with splitting *.nii.gz filename"""
    tmp = fname.split(".nii.gz")
    if( len(tmp) == 2 ):
        tmp[1] = '.nii.gz'
    else:
        tmp = os.path.splitext(fname)
    return tmp

def getModifiedFileName(fname,*mods):
    """create a new filename with the various modifications included in mods"""
    sep = '_'
    tmp = splitFileName(fname)
    newfname = "%s"%tmp[0]
    for m in mods:
        newfname += "%s%s"%(sep,m)
    if( tmp[1] not in mods ):    
        newfname += tmp[1]
    return newfname
